package com.campus.config.lifecycle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;

/**
 * 容器的初始化和  停止；停止的调用
 */
@Component
public class CustomLifecycle implements SmartLifecycle {
    private boolean isRunning=false;
    @Autowired
    private CustomInit customInit;

    @Override
    public void start() {
        System.out.println("容器启动");
        customInit.init();

    }

    @Override
    public void stop() {
        System.out.println("容器停止");
    }

    @Override
    public boolean isRunning() {
        System.out.println("验证容器状态");
        return isRunning;
    }

    @Override
    public boolean isAutoStartup() {
        System.out.println("来验证是否自动启动");
        return true;
    }

    @Override
    public void stop(Runnable callback) {
        System.out.println("停止回调");
    }

    @Override
    public int getPhase() {
        return 0;
    }
}
